

function get(e){
 return document.getElementById(e);
}
function getName(e){
 return document.getElementsByName(e);
}
function getTag(e){
 return document.getElementsByTagName(e);
}
var temp = null;
function showDialog(boxTitle , objName){
   var obj , formText , div ; 
   obj = get(objName);
	lockBg();
   if(get('titFont') != null && obj != null) {
	   get(temp).style.display = 'none';
       formText = obj.innerHTML;
	   obj.parentNode.removeChild(obj);
	   div = document.createElement("div");
	   div.id = objName;
	   div.innerHTML = formText;
	   get('mainContent').insertBefore(div);
       get('niftyform').style.display = 'block';
	   temp = objName;
	   get('titFont').innerText = boxTitle;	   
	   return ;
   }else if(get('titFont') != null && obj == null){
	   get(temp).style.display = 'none';
       get(objName).style.display = 'block';
	   get('niftyform').style.display = 'block';
	   temp = objName;
	   get('titFont').innerText = boxTitle;
	   return ;
   }
    formText = obj.innerHTML;
	obj.parentNode.removeChild(obj);
    temp = objName;
    div = document.createElement("div");
	var box = '<div class="winBox" id="niftyform"><div class="tit" id="niftyTitle">';
	box += '<span onclick="closeShowDialog();"></span>'+ boxTitle+'</div>';
	box += '<div class="con" ><div class="data" id="mainContent">';
	box += '<div id="'+objName+'">';
	box += formText;
	box += '</div></div></div>';
  div.innerHTML = box;
  document.documentElement.getElementsByTagName('body')[0].appendChild(div);
}

function lockBg(){
  var obj = document.getElementById('lockBg');
  if(obj == null){
     obj = document.createElement('div');
	 obj.id = 'lockBg';
	 obj.className = 'lock';
	 obj.style.width = document.documentElement.offsetWidth;
	 obj.style.height = document.documentElement.offsetHeight;
	 document.documentElement.getElementsByTagName('body')[0].appendChild(obj);
  }else{
    obj.style.display = 'block';
  }
}


function closeShowDialog(){
  var d = get('niftyform');
  try{
    d.style.display = 'none';
	get('lockBg').style.display = 'none';
  }catch(e){
    alert();
  }
}

 function message(){
  if(confirm("确定要删除吗") == true){
  	return true;    
  }
  return false;
}

function showMessage(text){
  var html = '<div style="background-color:#EAF1DC;border:1px solid #D3D9C6;padding:2px;">';
  html += '<h3 style="background-color:#C3D993;color:#1B4500;font-weight:bold;padding:4px;margin:0">提示</h3>';
  html += '<div style="padding:5px;">'+text+'</div></div>';
  var div = document.createElement("div");
  div.id = "showMessage";
  with(div.style){
	position = 'absolute';
	width = 120;
	top = document.documentElement.scrollTop + 200;
	left = '40%';
  }	  
  div.innerHTML = html;
  document.documentElement.getElementsByTagName("body")[0].appendChild(div);
  setTimeout(function(){div.parentNode.removeChild(div)}  , 1000);
}
